{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Swap Numbers LCCI"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Medium"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #LCCI"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #bit-manipulation #math"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #位运算 #数学"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: swapNumbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #交换数字"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>编写一个函数，不用临时变量，直接交换<code>numbers = [a, b]</code>中<code>a</code>与<code>b</code>的值。</p>\n",
    "\n",
    "<p><strong>示例：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入:</strong> numbers = [1,2]\n",
    "<strong>输出:</strong> [2,1]\n",
    "</pre>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>numbers.length == 2</code></li>\n",
    "\t<li><code>-2147483647 <= numbers[i] <= 2147483647</code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [swap-numbers-lcci](https://leetcode.cn/problems/swap-numbers-lcci/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [swap-numbers-lcci](https://leetcode.cn/problems/swap-numbers-lcci/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[0,2147483647]']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0],numbers[1]=numbers[1],numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        a=numbers[0]\n",
    "        numbers[0]=numbers[1]\n",
    "        numbers[1]=a\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return [numbers[1], numbers[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[::] = numbers[::-1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] += numbers[1]\n",
    "        numbers[1]  = numbers[0] - numbers[1]\n",
    "        numbers[0] -= numbers[1]\n",
    "        return numbers\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] = numbers[1] ^ numbers[0]\n",
    "        numbers[1] = numbers[1] ^ numbers[0]\n",
    "        numbers[0] = numbers[1] ^ numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0],numbers[1]=numbers[1],numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] = numbers[0]^numbers[1]\n",
    "        numbers[1] ^= numbers[0]\n",
    "        numbers[0] ^= numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return [numbers[1],numbers[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        a, b = numbers[0], numbers[1]\n",
    "        # 使用异或运算交换两个数的值\n",
    "        a = a ^ b\n",
    "        b = a ^ b\n",
    "        a = a ^ b\n",
    "        return [a,b]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0], numbers[1] = numbers[1], numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0],numbers[1]=numbers[1],numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return [numbers[1],numbers[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0],numbers[1] = numbers[1],numbers[0]\n",
    "        return numbers\n",
    "        \n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] = numbers[1] ^ numbers[0]\n",
    "        numbers[1] = numbers[1] ^ numbers[0]\n",
    "        numbers[0] = numbers[1] ^ numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] ^= numbers[1]\n",
    "        numbers[1] ^= numbers[0]\n",
    "        numbers[0] ^= numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0],numbers[1]=numbers[1],numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return numbers[::-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return numbers[-1::-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0], numbers[1] = numbers[1], numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        numbers[1] = numbers[1] ^ numbers[0]\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        \n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0],numbers[1] = numbers[1],numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return [numbers[1], numbers[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers.reverse()\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] ^= numbers[1]\n",
    "        numbers[1] ^= numbers[0]\n",
    "        numbers[0] ^= numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "       numbers[0] = numbers[0] ^ numbers[1]\n",
    "       numbers[1] = numbers[0] ^ numbers[1]\n",
    "       numbers[0] = numbers[0] ^ numbers[1]\n",
    "       return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "      numbers[0]=numbers[0]^numbers[1]\n",
    "      numbers[1]=numbers[0]^numbers[1]\n",
    "      numbers[0]=numbers[0]^numbers[1]\n",
    "      return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: list[int]) -> list[int]:\n",
    "        # numbers[0], numbers[1] = numbers[1], numbers[0]\n",
    "        numbers[0]=numbers[0]+numbers[1]\n",
    "        numbers[1]=numbers[0]-numbers[1]\n",
    "        numbers[0]=numbers[0]-numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        numbers[1] = numbers[0] ^ numbers[1]\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] = numbers[0]^numbers[1]\n",
    "        numbers[1] = numbers[0]^numbers[1]\n",
    "        numbers[0] = numbers[0]^numbers[1]\n",
    "\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return [numbers[0] ^ numbers[1] ^ numbers[0], numbers[1] ^ numbers[0] ^ numbers[1]] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0], numbers[1] = numbers[1], numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    @staticmethod\n",
    "    def swapNumbers(numbers):\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        numbers[1] = numbers[0] ^ numbers[1]\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0], numbers[1] = numbers[1], numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0]=numbers[0]^numbers[1]\n",
    "        numbers[1]=numbers[0]^numbers[1]\n",
    "        numbers[0]=numbers[0]^numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0],numbers[1]=numbers[1],numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return [numbers[1],numbers[0]]\n",
    "        \n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] ^= numbers[1]\n",
    "        numbers[1]  = numbers[0] ^ numbers[1]\n",
    "        numbers[0] ^= numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "       \n",
    "        numbers[0] = numbers[0] + numbers[1]\n",
    "        numbers[1] = numbers[0] - numbers[1]\n",
    "        numbers[0] = numbers[0] - numbers[1]\n",
    "        return [numbers[0],numbers[1]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        temp=numbers[0]\n",
    "        numbers[0]=numbers[1]\n",
    "        numbers[1]=temp\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] ^= numbers[1]\n",
    "        numbers[1] ^= numbers[0]\n",
    "        numbers[0] ^= numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return numbers[::-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] += numbers[1]\n",
    "        numbers[1] = numbers[0] - numbers[1]\n",
    "        numbers[0] = numbers[0] - numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return [numbers[1],numbers[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] ^= numbers[1]\n",
    "        numbers[1] ^= numbers[0]\n",
    "        numbers[0] ^= numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] ^= numbers[1]\n",
    "        numbers[1] ^= numbers[0]\n",
    "        numbers[0] ^= numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return [numbers[1],numbers[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0], numbers[1] = numbers[1], numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0],numbers[1] = numbers[1],numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] = numbers[0] + numbers[1]\n",
    "        numbers[1] = numbers[0] - numbers[1]\n",
    "        numbers[0] = numbers[0] - numbers[1]\n",
    "        return numbers\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] ^= numbers[1]\n",
    "        numbers[1] ^= numbers[0]\n",
    "        numbers[0] ^= numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        # numbers[0],numbers[1] = numbers[1],numbers[0]\n",
    "        # return numbers\n",
    "        a,b = numbers\n",
    "        a ^= b\n",
    "        b ^= a\n",
    "        a ^= b\n",
    "        return [a,b]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        numbers[1] = numbers[0] ^ numbers[1]\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[::1] = numbers[::-1]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0], numbers[1] = numbers[1], numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0],numbers[1]=numbers[1],numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        numbers[1] = numbers[1] ^ numbers[0]\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        \n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "        numbers[1] = numbers[0] ^ numbers[1]\n",
    "        numbers[0] = numbers[0] ^ numbers[1]\n",
    "    \n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "      numbers[0]=numbers[0]^numbers[1]\n",
    "      numbers[1]=numbers[0]^numbers[1]\n",
    "      numbers[0]=numbers[0]^numbers[1]\n",
    "      return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        # numbers[0],numbers[1] = numbers[1],numbers[0]\n",
    "        # return numbers\n",
    "        a,b = numbers\n",
    "        a ^= b\n",
    "        b ^= a\n",
    "        a ^= b\n",
    "        return [a,b]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return numbers[::-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        # [a, b] -> [a^b, b]\n",
    "        numbers[0] ^= numbers[1]\n",
    "        # [a^b, b] -> [a^b, a^b^b] = [a^b, a]\n",
    "        numbers[1] ^= numbers[0]\n",
    "        # [a^b, a] -> [a^b^a, a] = [b, a]\n",
    "        numbers[0] ^= numbers[1]\n",
    "        return numbers\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "\n",
    "        numbers[0],numbers[1] = numbers[1],numbers[0]\n",
    "        return numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def swapNumbers(self, numbers: List[int]) -> List[int]:\n",
    "        return numbers[::-1]\n"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
